package com.stu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.stu.entity.Student;
import com.stu.mapper.StudentMapper;
import com.stu.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentMapper studentMapper;


    @Override
    public void insertDemo() {

    }

    @Override
    public List<Student> list() {

        return studentMapper.selectList(null);
    }

    @Override
    public Page page(int page, int limit, String name) {
        Page pageInfo = new Page(page, limit);

        LambdaQueryWrapper<Student> queryWrapper = new LambdaQueryWrapper<>();
        if (null != name) {
            queryWrapper.like(Student::getName, name);
        }
        return studentMapper.selectPage(pageInfo, queryWrapper);
    }
}
